package mmoon.mmoonstory.blocks;

import mmoon.mmoonstory.MMoonUtils;
import mmoon.mmoonstory.interfaces.HasModel;
import mmoon.mmoonstory.interfaces.InitBlock;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockUnbreakable extends Block implements InitBlock, HasModel {
    public static final String ObjID = "unbreakable_block";
    private boolean breakable = false;

    public BlockUnbreakable() {
        super(MMoonUtils.UNBREAKABLE);
        this.setBlockUnbreakable();
        this.setHardness(Float.MAX_VALUE);
        this.setHarvestLevel("axe", Integer.MAX_VALUE);
        this.setHarvestLevel("shovel", Integer.MAX_VALUE);
        this.setHarvestLevel("pickaxe", Integer.MAX_VALUE);
        this.init(ObjID);
    }

    @Override
    public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state,
            int fortune) {
        drops.clear();
    }

    @Override
    public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player,
            boolean willHarvest) {
        return world.setBlockState(pos, this.getDefaultState(), world.isRemote ? 11 : 3);
    }

    @Override
    public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
        return false;
    }

    public boolean getBreakable() {
        return this.breakable;
    }

    public BlockUnbreakable setBreakable(boolean breakable) {
        this.breakable = breakable;
        return this;
    }
}
